<?php
/**
 * Created by PhpStorm.
 * User: shaowei
 * Date: 2019/1/23
 * Time: 上午10:34
 */

namespace App\Http\Model;


use Illuminate\Support\Facades\DB;

class AnalysisStat extends Base
{
    protected $table_room = "stat_room"; //room 表


    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    public function getRoomFlow($room_id){
        $res = DB::table($this->table_room)
            ->where('room_id' ,$room_id)
            ->where('statis_time','>=' ,date('Y-m-d' ,strtotime('-8 days')))
            ->orderBy('statis_time' ,'desc')
            ->limit(10)
            ->get();
        $res = $this->objToArray($res);
        return $res;
    }

    public function insertRoomFlow($data){
        return DB::table($this->table_room)->insertGetId($data);
    }

}
